<?php $this->placeholder('display-commercial1')->set(1)?>
<?php $this->headLink()->appendStylesheet(Ac_Util::getImageBaseUrl('/css/custom_search_result.v-'.AC_VERSION.'.css'))?>
<?php $this->headLink()->appendStylesheet(Ac_Util::getImageBaseUrl('/css/custom_ad_detail.v-'.AC_VERSION.'.css'))?>
<?php $this->headLink()->appendStylesheet(Ac_Util::getImageBaseUrl('/css/custom_serp.v-'.AC_VERSION.'.css'))?>
<?php $this->placeholder('container-class')->set('profile business')?>

<?php if (!empty($this->company->photos)):?>
    <?php $this->JQuery()->addJavascriptFile(Ac_Util::getImageBaseUrl('/js/sliderkit/jquery.easing.1.3.min.v-'.AC_VERSION.'.js'))?>
    <?php $this->JQuery()->addJavascriptFile(Ac_Util::getImageBaseUrl('/js/sliderkit/lightbox/jquery-lightbox/js/jquery.lightbox-0.5.pack.v-'.AC_VERSION.'.js'))?>
    <?php $this->JQuery()->addJavascriptFile(Ac_Util::getImageBaseUrl('/js/sliderkit/jquery.sliderkit.1.8.min.v-'.AC_VERSION.'.js'))?>
    <?php $this->headLink()->appendStylesheet(Ac_Util::getImageBaseUrl('/css/sliderkit/sliderkit-core.v-'.AC_VERSION.'.css'))?>
    <?php $this->headLink()->appendStylesheet(Ac_Util::getImageBaseUrl('/css/sliderkit/sliderkit-demos.v-'.AC_VERSION.'.css'))?>
    <?php $this->headLink()->appendStylesheet(Ac_Util::getImageBaseUrl('/js/sliderkit/lightbox/jquery-lightbox/css/jquery.lightbox-0.5.v-'.AC_VERSION.'.css'))?>
    <!--[if IE 6]><link rel="stylesheet" type="text/css" href="<?php echo Ac_Util::getImageBaseUrl('/css/sliderkit/sliderkit-demos-ie6.v-'.AC_VERSION.'.css')?>" /><![endif]-->
    <!--[if IE 7]><link rel="stylesheet" type="text/css" href="<?php echo Ac_Util::getImageBaseUrl('/css/sliderkit/sliderkit-demos-ie7.v-'.AC_VERSION.'.css')?>" /><![endif]-->
    <!--[if IE 8]><link rel="stylesheet" type="text/css" href="<?php echo Ac_Util::getImageBaseUrl('/css/sliderkit/sliderkit-demos-ie8.v-'.AC_VERSION.'.css')?>" /><![endif]-->
    <?php $this->JQuery()->javascriptCaptureStart()?>
            $j(window).load(function(){ //$(window).load() must be used instead of $(document).ready() because of Webkit compatibility
                $j(".photosgallery-captions").sliderkit({
                    navscrollatend: true,
                    mousewheel:false,
                    keyboard:true,
                    shownavitems:9,
                    auto:false,
                    fastchange:true,
                    start:0
                });
                var lightboxPath = "js/sliderkit/lightbox/jquery-lightbox/";
                $j("a[rel='group1']").lightBox({
                    imageLoading:lightboxPath+"images/lightbox-ico-loading.gif",
                    imageBtnPrev:lightboxPath+"images/lightbox-btn-prev.gif",
                    imageBtnNext:lightboxPath+"images/lightbox-btn-next.gif",
                    imageBtnClose:lightboxPath+"images/lightbox-btn-close.gif",
                    imageBlank:lightboxPath+"images/lightbox-blank.gif"
                });
            });
    <?php $this->JQuery()->javascriptCaptureEnd()?>

<?php endif;?>

<?php if(!empty($this->company->mailing_address)):?>
    <?php $this->headScript()->appendFile('http://api.map.baidu.com/api?v=1.2&services=true')?>
    <?php $this->JQuery()->javascriptCaptureStart()?>
        var  map =  new  BMap.Map ( "map_container" );  
        map.addControl ( new  BMap.NavigationControl ()); 
        map.centerAndZoom ( new  BMap.Point (116.404, 39.915), 11);  
        // Create a geocoding service instance  
        var  myGeo =  new  BMap.Geocoder ();  
        // Display the results on the map and adjust the map view  
        myGeo.getPoint ( "<?php echo str_replace("\r\n", '', $this->company->mailing_address)?>" ,  function (Point) {  
        //myGeo.getPoint ( "静安区，北京西路1565，1804室" ,  function (Point) {  
          if  (Point) {  
            map.centerAndZoom (Point, 16);  
            map.addOverlay ( new  BMap.Marker (Point));  
          }  
        },  "香港" ); 
        //},  "上海市" ); 
    <?php $this->JQuery()->javascriptCaptureEnd()?>
<?php endif;?>

<article class="article">
    <section class="main_section">
        <section class="user info box">
            <figure>
                <a href="<?php echo $this->company->url();?>">
                    <img src="<?php echo $this->thumbnail()->scale($this->company->image, 96, 96, true, true);?>" alt="<?php echo $this->company->company_name?>">
                </a>
            </figure>
            <h1>
                <em><?php echo $this->company->company_name?></em>
                <span class="location"><?php echo $this->t('位于')?><a href="#"><?php echo $this->company->mailing_address?></a></span>
                
                <span class="tel"><?php echo $this->t('联系电话')?><a href="#"><?php echo $this->company->contact_phone?></a></span>
            </h1>
            <ul>
                <li>
                    <a href="#"><span><?php echo $this->t('关注')?></span><?php echo (int)$this->company->count_following?></a>
                </li>
                <li><a href="#"><span><?php echo $this->t('粉丝')?></span><?php echo (int)$this->company->count_followers?></a></li>
                <li><a href="#"><span><?php echo $this->t('被喜欢')?></span><?php echo (int)$this->company->count_likes?></a></li>
            </ul>
            <section class="func">
                <?php $is_follow = Model_Follow::isFollowing($this->company->_id);?>
                <a href="#" rel="<?php echo $this->geturl(($is_follow ? 'unfollow' : 'follow'),'follow', array('id' => (string)$this->company->_id))?>" class="follow to_follow <?php echo ($is_follow ? 'selected' : '')?>"><span><?php echo $this->t('关注')?><em><?php echo Model_Follow::getCountFollowers($this->company->_id)?></em></span></a>
                <!-- JiaThis Button BEGIN -->
                <div id="jiathis_style_32x32">
                    <span class="jiathis_txt">分享到：</span>
                    <a class="jiathis_button_qzone" title="分享到QQ空间"><span class="jiathis_txt jtico jtico_qzone"></span></a>
                    <a class="jiathis_button_tsina" title="分享到新浪微博"><span class="jiathis_txt jtico jtico_tsina"></span></a>
                    <a class="jiathis_button_tqq" title="分享到腾讯微博"><span class="jiathis_txt jtico jtico_tqq"></span></a>
                    <a class="jiathis_button_renren" title="分享到人人网"><span class="jiathis_txt jtico jtico_renren"></span></a>
                    <a class="jiathis_button_kaixin001" title="分享到开心网"><span class="jiathis_txt jtico jtico_kaixin001"></span></a>
                    <a target="_blank" class="jiathis jiathis_txt jtico jtico_jiathis" href="http://www.jiathis.com/share"></a>
                </div>
                <script charset="utf-8" src="http://v2.jiathis.com/code/jia.js" type="text/javascript"></script>
                <!-- JiaThis Button END -->
            </section>
        </section>

        <section class="main_info box">
            <section class="left column">
                <?php if(!empty($this->company->photos)):?>
                    <section class="photo">
                        <h3>共<span><?php echo count($this->company->photos);?></span><?php echo $this->t('张相片')?></h3>
                        <!-- Start Advanced Gallery Html Containers -->
                        <div class="sliderkit photosgallery-captions">
                            <div class="sliderkit-nav">
                                <div class="sliderkit-nav-clip">
                                    <ul>
                                        <?php foreach($this->company->photos as $k => $photo) :?>
                                            <li>
                                                <a href="<?php echo $this->thumbnail()->scale($photo)?>" title=""> <img src="<?php echo $this->thumbnail()->scale($photo, 51, 51);?>" alt=""></a>
                                            </li>
                                        <?php endforeach;?>
                                    </ul>
                                </div>
                            </div>
                            <div class="sliderkit-panels">
                                <?php foreach($this->company->photos as $k => $photo) :?>
                                    <div class="sliderkit-panel">
                                        <a href="<?php echo $this->thumbnail()->scale($photo)?>" title="[title]" rel="group1">
                                            <img src="<?php echo $this->thumbnail()->scale($photo, 568, 424);?>" alt="[Alternative text]" />
                                        </a>
                                    </div>
                                <?php endforeach;?>
                            </div>
                        </div>
                    </section>
                <?php endif;?>
                <section class="ad">
                    <a href="#"><img src="images/ad_728_90.jpg"></a>
                </section>
                <section class="info">
                    <h3><?php echo $this->t('详细资料')?></h3>
                    <section class="more">
                        <?php if(!empty($this->company->mailing_address)):?>
                            <section class="map">
                                <h3><?php echo $this->t('地图资讯')?></h3>
                                <dl>
                                    <dd>
                                        <div id="map_container" style="width:200px; height:200px;"></div>
                                    </dd>
                                </dl>
                            </section>
                        <?php endif;?>
                        <section class="contact">
                            <h3><?php echo $this->t('联络资料')?></h3>
                            <dl>
                               <?php if(!empty($this->company->contact_name)):?>
                                    <dt><?php echo $this->t('姓名')?></dt>
                                    <dd><?php echo $this->company->contact_name?></dd>
                                <?php endif;?>
                                <?php if(!empty($this->company->contact_position)):?>
                                    <dt><?php echo $this->t('聯絡人工作岗位')?></dt>
                                    <dd><?php echo $this->company->contact_position?></dd>
                                <?php endif;?>
                                <?php if(!empty($this->company->contact_department)):?>
                                    <dt><?php echo $this->t('部门')?></dt>
                                    <dd><?php echo $this->company->contact_department?></dd>
                                <?php endif;?>
                                <?php if(!empty($this->company->contact_phone)):?>
                                    <dt><?php echo $this->t('电话')?></dt>
                                    <dd><?php echo $this->company->contact_phone?></dd>
                                <?php endif;?>
                                <?php if(!empty($this->company->contact_email)):?>
                                    <dt><?php echo $this->t('邮箱')?></dt>
                                    <dd class="email"><?php echo $this->company->contact_email?></dd>
                                <?php endif;?>
                                <?php if(!empty($this->company->contact_messenger)):?>
                                    <dt><?php echo $this->t('MSN/QQ')?></dt>
                                    <dd><?php echo $this->company->contact_messenger?></dd>
                                <?php endif;?>
                            </dl>
                        </section>
                    </section>
                    <section class="general">
                        <?php if(!empty($this->company)):?>
                            <dl>
                                <dt><?php echo $this->t('公司名称')?></dt>
                                <dd><a href="<?php echo $this->company->url()?>"><?php echo $this->company->company_name;?></a></dd>
                            </dl>
                        <?php endif;?>

                        <?php if(!empty($this->company->business_category)):?>
                            <dl>
                                <dt><?php echo $this->t('业务性质')?></dt>
                                <dd>
                                    <?php 
                                    $dir = Model_Category::find($this->company->business_category);
                                    if (!empty($dir)) {
                                        echo $dir->name; 
                                    }
                                    ?>
                                </dd>
                            </dl>
                        <?php endif;?>

                        <?php if (!empty($this->company->number_employees)):?>
                            <dl>
                                <dt><?php echo $this->t('员工人数')?></dt>
                                <dd><?php echo $this->company->number_employees?></dd>
                            </dl>
                        <?php endif;?>

                        <?php if (!empty($this->company->website)): ?>
                            <dl>
                                <dt><?php echo $this->t('企业网站')?></dt>
                                <?php $ws = trim($this->company->website, chr(0xC2).chr(0xA0));?>
                                <dd><a href="http://<?php echo str_replace('http://', '', trim($ws))?>" rel="nofollow" target="_blank"><?php echo $ws?></a></dd>
                            </dl>
                        <?php endif;?>

                        <?php if (!empty($this->company->weibo)): ?>
                            <dl>
                                <dt><?php echo $this->t('微博网址')?></dt>
                                <?php $ws = trim($this->company->weibo, chr(0xC2).chr(0xA0));?>
                                <dd><a href="http://<?php echo str_replace('http://', '', trim($ws))?>" rel="nofollow" target="_blank"><?php echo $ws?></a></dd>
                            </dl>
                        <?php endif;?>

                        <?php if (!empty($this->company->phone)):?>
                            <dl>
                                <dt><?php echo $this->t('公司电话')?></dt>
                                <dd><?php echo $this->company->phone?></dd>
                            </dl>
                        <?php endif;?>

                        <?php if (!empty($this->company->fax)):?>
                            <dl>
                                <dt><?php echo $this->t('传真号码')?></dt>
                                <dd><?php echo $this->company->fax?></dd>
                            </dl>
                        <?php endif;?>

                        <?php if (!empty($this->company->location)): ?>
                            <dl>
                                <dt><?php echo $this->t('公司地址')?></dt>
                                <dd>
                                <?php
                                /*
                                    $id_parent = $this->company->location->path[0];
                                    $parent = Model_Location::one(array('_id' => new MongoId($id_parent)));
                                    echo ($this->company->location->name != "Online Only") ? $this->company->location->name.', '.$parent->name : $this->company->location->name;
                                    */

                                ?>
                                    <?php if(!empty($this->company->area_l2)):?>
                                        <a href="<?php echo Ac_Util::getCrossLink($this->company->area_l2->area_l1->_id, 'area_l1', $this->company, $this->geturl('regular','search'))?>"><?php echo $this->company->area_l1?></a>,
                                        <a href="<?php echo Ac_Util::getCrossLink($this->company->area_l2->_id, 'area_l2', $this->company, $this->geturl('regular','search'))?>"><?php echo $this->company->area_l2?></a>
                                    <?php endif;?>                                
                                </dd>
                            </dl>
                        <?php endif ?>                            

                        <?php if (!empty($this->company->mailing_address)):?>
                            <dl>
                                <dt><?php echo $this->t('地址')?></dt>
                                <dd><?php echo $this->company->mailing_address?></dd>
                            </dl>
                        <?php endif;?>
                    </section>
                    <section class="desc">
                        <h3><?php echo $this->t('描述')?></h3>
                        <dl>
                            <dd>
                                <?php   $text = $this->company->about;
                                        if (preg_match_all('#<a[^<]*(http://\S*)\s#u', $text.' ', $matches)) {
                                            foreach ($matches[1] as $match) {
                                                 $text = str_replace($match, '<a rel="nofollow" target="_blank" href="'.Model_Link::getTrackingLink(trim($match)).'">'.$match.'</a>', $text);
                                            }
                                        }

                                        if (preg_match_all('#([^\/]www\S*)\s#u', $text.' ', $matches)) {
                                            foreach ($matches[1] as $match) {
                                                 $text = str_replace($match, '<a rel="nofollow" target="_blank" href="'.Model_Link::getTrackingLink('http://'.trim($match)).'">'.$match.'</a>', $text);
                                            }
                                        }
                                        if (empty($text)) {
                                           // echo $this->t('No description provided');
                                        } else {
                                            echo nl2br($text);
                                        }
                                ?>
                            </dd>
                        </dl>
                    </section>

            </section>
        </section>
        <section class="right column">
            <section class="ad medium"> <a href="#"><img src="images/ad_300_250.jpg"></a> </section>
            <?php $list = $this->company->followers()?>
            <?php if ($list->count() > 0):?>
                <section class="friend user">
                    <h3><span><?php echo (int)$list->count()?></span><?php echo $this->t('人關注了這個公司')?></h3>
                    <ul>
                        <?php foreach($list as $user):?>
                            <?php 
                                $item = $user->user_followed;
                                if ($item instanceof Model_Company) {
                                    $name = $item->company_name;
                                    $url  = $item->url();
                                    $photo = $item->photo;
                                } else {
                                    $name = $item->username;
                                    $url  = $item->url();
                                    $photo = $item->image;
                                }
                            ?>
                            <li>
                                <?php if(!empty($name)):?>
                                    <figure>
                                       <a href="<?php echo $url;?>">
                                           <img src="<?php echo $this->thumbnail()->scale($photo, 54, 54, true, true);?>" alt="<?php echo $name?>">
                                       </a>
                                    </figure>
                                    <h2><a href="<?php echo $url?>"><?php echo $name?></a></h2>
                                <?php else:?>
                                    <figure>
                                       <a href="#">
                                           <img src="<?php echo $this->thumbnail()->scale('', 54, 54, true, true);?>" alt="anonymous">
                                       </a>
                                    </figure>
                                    <h2><a href="#"><?php echo $this->t('隐者猫')?></a></h2>
                                <?php endif;?>
                            </li>

                        <?php endforeach;?>
                    </ul>
                </section>
            <?php endif;?>

            <?php $list = $this->company->following()?>
            <?php if ($list->count() > 0):?>
                <section class="follow user">
                    <h3><?php echo $this->t('他也關注了')?><span><?php echo (int)$list->count()?></span><?php echo $this->t('個單位')?></h3>
                    <ul>
                        <?php foreach($list as $user):?>
                            <?php $item = $user->user;?>
                            <li>
                                <?php if(!empty($item->username)):?>
                                    <figure>
                                       <a href="<?php echo $item->url();?>">
                                           <img src="<?php echo $this->thumbnail()->scale($item->photo, 54, 54, true, true);?>" alt="<?php echo $item->name?>">
                                       </a>
                                    </figure>
                                    <h2><a href="<?php echo $item->url()?>"><?php echo $item->username?></a></h2>
                                <?php else:?>
                                    <figure>
                                       <a href="#">
                                           <img src="<?php echo $this->thumbnail()->scale('', 54, 54, true, true);?>" alt="anonymous">
                                       </a>
                                    </figure>
                                    <h2><a href="#"><?php echo $this->t('隐者猫')?></a></h2>
                                <?php endif;?>
                            </li>
                        <?php endforeach;?>
                    </ul>
                </section>
            <?php endif;?>
      </section>

        <?php if($this->listing_number>0):?>
            <?php $this->partial()->setObjectKey('object');?>
            <?php 
                echo $this->Partial(
                    'index/display-list-ad.phtml',
                    'user',  
                    array(
                        'obj'            => $this->company,
                        'no-facet'       => true,
                        'list'           => $this->list, 
                        'listing_number' => $this->listing_number, 
                        'page'           => $this->page, 
                        'per_page'       => $this->per_page, 
                        'sort'           => $this->sort,
                    )
                )
            ?>
        <?php endif;?>

    </section>
    <aside class="aside">
    </aside>
</article>
